<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%@page import="com.lmpop.trade.ts_category.*" %>
<%@page import="com.lmpop.trade.ts_categoryattr.*" %>
<%@page import="com.lmpop.trade.ti_brand.Ti_brandInfo" %>
<%@page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.trade.ts_memlevel.Ts_memlevelInfo" %>
<%@page import="com.lmpop.trade.ti_goods.*" %>
<%@page import="com.lmpop.trade.tb_goodstock.Tb_goodstockInfo" %>
<%@page import="com.lmpop.trade.ti_attach.Ti_attachInfo" %>

<jsp:useBean id="randomId" class="com.lmpop.frame.util.RandomID" scope="page" />  

<html>
<%

	String para ="/program/admin/checkgoods/index.jsp";
	String goods_id="";
	if(request.getParameter("goods_id")!=null) goods_id = request.getParameter("goods_id");

	Ti_goodsInfo ti_goodsInfo = new Ti_goodsInfo();
	List list = ti_goodsInfo.getListByPk(goods_id);
	Hashtable map = new Hashtable();
	if(list!=null && list.size()>0) map = (Hashtable)list.get(0);
  	
	String goods_no="",class_attr="",brand_id="",goods_name="",member_price="",org_price="",market_price="",sale_price="";
	String send_inter="",buy_inter="",weight="",stock_in="",stock_num="",stock_out="",stock_down="",price_unit="",state_code="" ;
	String state_date="",ship_fare="",keywords="",outline="",goods_desc="",remark="",link_goods="",link_fit="",attr_desc="";
	if(map.get("goods_no")!=null) goods_no = map.get("goods_no").toString();
	if(map.get("class_attr")!=null) class_attr = map.get("class_attr").toString();
	if(map.get("brand_id")!=null) brand_id = map.get("brand_id").toString();
	if(map.get("goods_name")!=null) goods_name = map.get("goods_name").toString();
	if(map.get("member_price")!=null) member_price = map.get("member_price").toString();
	if(map.get("org_price")!=null) org_price = map.get("org_price").toString();
	if(map.get("market_price")!=null) market_price = map.get("market_price").toString();
	if(map.get("sale_price")!=null) sale_price = map.get("sale_price").toString();
	if(map.get("send_inter")!=null) send_inter = map.get("send_inter").toString();
	if(map.get("buy_inter")!=null) buy_inter = map.get("buy_inter").toString();
	if(map.get("weight")!=null) weight = map.get("weight").toString();
	if(map.get("stock_in")!=null) stock_in = map.get("stock_in").toString();
	if(map.get("stock_num")!=null) stock_num = map.get("stock_num").toString();
	if(map.get("stock_out")!=null) stock_out = map.get("stock_out").toString();
	if(map.get("stock_down")!=null) stock_down = map.get("stock_down").toString();
	if(map.get("price_unit")!=null) price_unit = map.get("price_unit").toString();
	if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
	if(map.get("state_date")!=null) state_date = map.get("state_date").toString();
	if(map.get("ship_fare")!=null) ship_fare = map.get("ship_fare").toString();
	if(map.get("keywords")!=null) keywords = map.get("keywords").toString();
	if(map.get("outline")!=null) outline = map.get("outline").toString();
	if(map.get("goods_desc")!=null) goods_desc = map.get("goods_desc").toString();
	if(map.get("remark")!=null) remark = map.get("remark").toString();
	if(map.get("link_goods")!=null) link_goods = map.get("link_goods").toString();
	if(map.get("link_fit")!=null) link_fit = map.get("link_fit").toString();
	if(map.get("attr_desc")!=null) attr_desc = map.get("attr_desc").toString();
	String cust_id="";    
	if(map.get("cust_id") != null)
	{
		  cust_id = map.get("cust_id").toString();
	}
	  
	if (request.getParameter("class_attr") != null && !request.getParameter("class_attr").equals(""))
	{
		class_attr = request.getParameter("class_attr");
	}
  
   
    Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
    Map catMap = ts_categoryInfo.getCatClassMap("2");
    Ti_brandInfo  ti_brandInfo = new  Ti_brandInfo();
    Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
    Ts_memlevelInfo ts_memlevelInfo =new Ts_memlevelInfo(); 
    Tb_goodstockInfo tb_goodstockInfo = new Tb_goodstockInfo();    
                                                            
    String brand_select =  ti_brandInfo.getBrandSelectByCatId(class_attr,brand_id); 
    
	String brand_name ="";
	
	List  bList  = ti_brandInfo.getListByPk(brand_id);
	
	if(bList!=null && bList.size()>0)
	{
	  Hashtable bmap =(Hashtable)bList.get(0);
	  if(bmap.get("title")!=null)
	  {
	     brand_name = bmap.get("title").toString();
	  }
	 
	}
	
	String s_price_unit = tb_commparaInfo.getOneComparaPcode1("18",price_unit); 
	
	
	List memLevelList =ts_memlevelInfo.getMemLevelAll();  
  
                                                    
    String catAttr[] = class_attr.split("\\|");
    String cat_names ="";  
    if(!class_attr.equals(""))
    {
      String catIds[] =	class_attr.split("\\|");	
      for(String catId:catIds)
      {
         if(catMap!=null)
         {
             if(catMap.get(catId)!=null)
             {
              cat_names +=catMap.get(catId).toString()+" > ";                 
             }                  
         
         }                 
      }		    
	}
  
  //-------- get cat attr  
  
  Ts_categoryattrInfo ts_categoryattrInfo = new Ts_categoryattrInfo();
	List attList = new ArrayList();
  if(!catAttr[catAttr.length-1].equals(""))
  {
    	attList = ts_categoryattrInfo.getListByClassId(catAttr[catAttr.length-1]);
  }  
  
  Hashtable stockMap = tb_goodstockInfo.getGoodStockByGoodsId(goods_id);
  String one_price = "",before_num="",now_num="";
  if(stockMap.get("one_price")!=null)
  {
    one_price = stockMap.get("one_price").toString();  
  }
  if(stockMap.get("before_num")!=null)
  {
    before_num = stockMap.get("before_num").toString();  
  }
  if(stockMap.get("now_num")!=null)
  {
    now_num = stockMap.get("now_num").toString();  
  }	 
  
  
  
    List attrValueList = new ArrayList();
	int attrsize = 0,valuesize = 0;
	
	String publish_user_id="";
	//if(session.getAttribute("session_cust_id")!=null){
	//     cust_id  =session.getAttribute("session_cust_id").toString();
	//}
  
  if(session.getAttribute("session_user_id")!=null){
	     publish_user_id  =session.getAttribute("session_user_id").toString();
	}
                          
     
%>	
  <head>
    <title>审核商品</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
    <link href="/program/admin/index/css/thickbox.css" rel="stylesheet" type="text/css">
 
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/thickbox.js"></script>
    <script type="text/javascript" src="js_goods.js"></script>
    <script src="js_link.js" type="text/javascript"></script>
 
	<style>
   .button_css{height:25px; width:135px; font-size: 10pt; color: #fff; border: 1px #cabca3 solid; 
              background:url(/program/admin/index/images/an_01.gif) repeat-x; cursor:pointer;padding:0 3px 0 3px;}
                                                                                                                  
   .button_s_css{height:20px; width:55px; font-size: 12px; color: #fff; border: 1px #cabca3 solid; 
            background:url(/program/admin/index/images/an_01.gif) repeat-x; cursor:pointer;padding:0 3px 0 3px;}
 </style>
 
 

 </head>

<body>
	<h1>审核商品</h1>
	     
	<form action="/doTradeReg.do" method="post" name="addForm">
	 
  <table width="100%" cellpadding="1" cellspacing="1" border="0" class="listtab">
		
			<tr>
					<td  colspan="4">
				   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">基本信息</span>			</td>
		    </tr>
			
			<tr>
			<td align="right" width="20%">
				你选择的类目:			
			</td>
			<td  colspan="3">
			   <font color="red"><%=cat_names%></font> 
			</td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				  产品属性:				
			</td>
			<td colspan="3">
			   <span class="STYLE5" style="color:#FF7300;">产品属性填写的越少，越容易流失被搜索到的机会！建议您尽可能完整填写！</span> <br/>
			 		 					
			
			 <%
			      	if( attList != null && attList.size() > 0 ) {
								 attrsize = attList.size();
								 Hashtable attrmap = new Hashtable();
							 	 for( int i = 0; i < attrsize; i++ )
								 {
								 	 attrmap = ( Hashtable )attList.get(i);
									 String attr_id = "",attr_name = "",default_tag ="", con_type="",attrStr = "",isfill="";
									 if( attrmap.get("attr_id") != null )
									 {
									 	 attr_id = attrmap.get("attr_id").toString();
									 }
									 if( attrmap.get("attr_name") != null )
									 {
									 	 attr_name = attrmap.get("attr_name").toString();
									 }
									 if( attrmap.get("default_tag") != null )  // if fill in or not									 
									 {
									 	 default_tag = attrmap.get("default_tag").toString();
									 }
									 if( attrmap.get("con_type") != null )
									 {
									 	 con_type = attrmap.get("con_type").toString();
									 }
									 if( default_tag.equals("0"))
									 {
									 	 isfill = " <span style='color:red;'>*</span>";
									 }
									
									 
						%>
						
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
			        <tr>
			          <td width="18%" height="35" align="right" style="background:#F9F9F9;">
			          	 &nbsp;<%=attr_name%><%=isfill%>
			          </td>
			          <td width="48%" style="background:#F9F9F9;">
			          	
			          								  
								  <input type="hidden" name="attr_id<%=i%>" id="attr_id<%=i%>" value="<%=attr_id%>" /> 
								  <input type="hidden" name="attr_name<%=i%>" id="attr_name<%=i%>" value="<%=attr_name%>" />
								  <input type="hidden" name="con_type<%=i%>" id="con_type<%=i%>" value="<%=con_type%>" />
								  <input type="hidden" name="default_tag<%=i%>" id="default_tag<%=i%>" value="<%=default_tag%>" />
			          	<%
			          			String attrValue = "";
											
										  if(con_type.equals("0"))
											{
											 	 
											 	 attrValue = ts_categoryattrInfo.getSelectItems(attr_id,attr_desc);
									     									
									%>	
											   <select class="input" name="attr_value<%=i%>" id="attr_value<%=i%>" style="height:20px;">
											   		 <%=attrValue%>
											   </select>
									<%			
											}
												
											if( con_type.equals( "1") )
											{
                                             attrValue= ts_categoryattrInfo.getInputItems(attr_id,attr_desc);												 
									 %>
										<%=attrValue%>
									<%			
											}
											if( con_type.equals( "2") ){
													attrValueList = ts_categoryattrInfo.getListByPk(attr_id);
                                                    attrValue = ts_categoryattrInfo.getCheckboxItems(attr_id,attr_desc);												  
												    if( attrValueList != null && attrValueList.size() > 0 ) 
													{
                           
													Hashtable valuemap = (Hashtable)attrValueList.get(0);
													String default_value="";                           
													if( valuemap.get("default_value") != null )
													{
														default_value = valuemap.get("default_value").toString();
													}
													  
                                                      String attrValues[] =	default_value.split("\\|");												  
													  valuesize = attrValues.length;
													  for( int j = 0; j < valuesize; j++ ) 
													  {
									     %>
												     <%
													   if(attrValue.indexOf(attrValues[j])>-1)
													   out.print(attrValues[j]+" ");
													  
													  %>	
												    									
											 <%	   
											      }
											 %>  	
											  
											  <input type="hidden" name="valuesize<%=i%>" id="valuesize<%=i%>" value="<%=valuesize%>" /> 

											  <%
											}
										}
									%>		
			          	
			            <span class="STYLE5"></span>
			          </td>
			          <td width="36%"></td>
					  	</tr>
			      </table>
			      <%		}
							 }
						%>
						
						  <input type="hidden" name="attrsize" id="attrsize" value="<%=attrsize%>" />
			    </td>
       </tr>
	     
     <tr>
			<td align="right" width="20%">
				 商品名称<font color="red">*</font>		
			</td>
			<td colspan="3">
				  <%=goods_name%>
			 </td>
		</tr>
  
      <tr>
			<td align="right" width="20%">
				 商品关键字<font color="red">*</font>		
			</td>
			<td colspan="3">
				 <%=keywords%>
			 </td>
		</tr>
        
          <tr>
			  <td align="right" width="20%">商品编号<font color="red">*</font></td>	   
			  <td width="18%">
			    <%=goods_no%>
			  </td>
			  <td width="12%" align="right">商品品牌:</td>
			  <td width="60%">
			   <%=brand_name%>		  
			  </td>
	 </tr>
    
     <tr>
			<td align="right" width="20%">
				商品缩略图:			
			</td>
			<td colspan="3">
			 
			  <%
			       Ti_attachInfo ti_attachInfo = new Ti_attachInfo();
				   
				   String img_path =  ti_attachInfo.getFilePathByAttachrootid(goods_id);
				   if(img_path.equals(""))
				   {
						 img_path ="/program/admin/images/cpwu.gif";            
				   }              
			  
			  
			  %>
			  
		        <img src="<%=img_path%>" border="0" width="85" height="85" />
			
			</td>
		</tr> 
    
    
   <tr>
			  <td align="right" width="20%">市场价<font color="red">*</font></td>	   
			  <td width="18%">
			     <%=market_price%>
			  </td>
			  <td width="12%" align="right">进价<font color="red">*</font></td>
			  <td width="60%">
			     <%=org_price%>
			  </td>
	 </tr>
    
    
        <tr>
			<td align="right" width="20%">销售价<font color="red">*</font></td>	   
			<td width="18%">
                 <%=sale_price%>
			</td>
			<td width="72%" colspan="2">
        </td>
			  </td>
	 </tr>
      
    <tr>
			<td align="right" width="20%">
				会员价格:			
			</td>
			<td colspan="3">
			 
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
			 
			 
			 <%
        int level_num=0;			  
			  if(memLevelList !=null && memLevelList.size()>0){	
			  
              level_num=	memLevelList.size();		       
			        for(int i=0;i<memLevelList.size();i++){
              Hashtable lmap =(Hashtable)memLevelList.get(i);
              String user_class="",class_name="",discount=""; 
              if(lmap.get("user_class")!=null){
                    user_class =lmap.get("user_class").toString();             
              } 
              if(lmap.get("class_name")!=null){
                    class_name =lmap.get("class_name").toString();             
              }
              if(lmap.get("discount")!=null){
                    discount =lmap.get("discount").toString();             
              }
              String  mb_price[] = member_price.split(",");
               
              String class_price ="";               
              for(int j=0;j<mb_price.length;j++)
              {
                   String mb_one_price[] = mb_price[j].split("\\|"); 
                   if(mb_one_price.length>1)
                   {
                       if(user_class.equals(mb_one_price[0]))
                       {
                          class_price = mb_one_price[1];
                          break;                     
                       }
                                         
                   }             
               }   
              
                         
			%>
		 <tr>
		   
		    <td width="18%" height="35" align="right" style="background:#F9F9F9;">

			  <%=class_name%>
      
       </td>
			
			<input type="hidden" name="userLevelId<%=i%>" id="userLevelId<%=i%>"	value="<%=user_class%>" />
			<td width="48%" style="background:#F9F9F9;">
		     <%=class_price%>
		  </td>
    
        <td width="36%"></td>
 
   	</tr>

		
			<%
			  }
			}
			%>
			
		 </table>
	
			
			
			
			</td>
		</tr>
     
     	<input type="hidden" name="level_num" id="level_num" value="<%=level_num%>"/>        
            
      <tr>
			<td align="right" width="20%">
				是否为免运费商品:			
			</td>
			<td colspan="3">
               <%
			      if(ship_fare.equals("1"))out.print("是");
			      if(ship_fare.equals("0"))out.print("否");
			   %> 
	
			</td>
		</tr>
  
  
   <tr>
			 <td align="right" width="20%">赠送积分数<font color="red">*</font></td>	   
			  <td width="18%">
			    <%=send_inter%>
			  </td>
			  <td width="12%" align="right">积分购买数<font color="red">*</font></td>
			  <td width="60%">
			  <%=buy_inter%>
			  </td>
	 </tr>
    
    
   <tr>
			 <td align="right" width="20%">商品重量<font color="red">*</font></td>	   
			  <td width="18%">
			  <%=weight%>
			     
<!--			     <font color="#666666">(克)</font>-->		     
			  </td>
			  <td width="12%" align="right">计价单位<font color="red">*</font></td>
			  <td width="60%">
         
             <%=s_price_unit%>           
                          			 
			  </td>
	  </tr>
    
 	<tr>
					<td  colspan="4">
				   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">库存信息</span>			</td>
		    </tr>
    
    
    
    <tr>
			 <td align="right" width="20%">库存初始量<font color="red">*</font></td>	   
			  <td width="18%">
                  <%=stock_in%>
			  </td>
			  <td width="12%" align="right">最低库存量<font color="red">*</font></td>
			  <td width="60%">
			    <%=stock_down%>
			  </td>
	  </tr>
     
 
     <tr>
			 <td align="right" width="20%">商品库存单价<font color="red">*</font></td>	   
			  <td width="18%">
			    <%=one_price%>
			  </td>
			  <td width="12%" align="right"></td>
			  <td width="60%">
			    
			  </td>
	  </tr>
    
	<tr>
					<td  colspan="4">
				   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">详细信息</span>			</td>
		    </tr>
       
  <tr>
			<td align="right" width="20%">
				商品概述:			
			</td>
			<td colspan="3">
<%=outline%>	
			</td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				商品详细描述:			
			</td>
			<td colspan="3">
			  <textarea name="goods_desc"><%=goods_desc%></textarea>
			<script type="text/javascript" src="/program/plugins/ckeditor/ckeditor.js"></script>
			<script type="text/javascript">
			  //CKEDITOR.replace('goods_desc');
			   CKEDITOR.replace('goods_desc');  
			</script>
			
			</td>
		</tr>     
      
     	<tr>
					<td  colspan="4">
				   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">关联信息</span>			</td>
		    </tr>
 
      
         
     <tr>
			<td align="right" width="20%">
				同类商品:			
			</td>
			<td colspan="3">
       
			  
       <span id="g_goods_table">
           <%
           
           if(!link_goods.trim().equals("")){           
           %>       
          <table width='100%' border='0' cellspacing='0' cellpadding='0' >
          
			   <%
            String l_g_goods[] = link_goods.split("\\|");	
            for(int i=0;i<l_g_goods.length;i++){
              int k =i+1;	
              String l_g_name = ti_goodsInfo.getGoodsNameById(l_g_goods[i]);
              if(l_g_name.length()>28)
              {
                  l_g_name =l_g_name.substring(0,28);              
              }		   
			  
			   %>        
             <tr id="g_spandiv<%=k%>">
           	<td width='5%' height='15' align='right' style='background:#F9F9F9;'>
             	<font color="#666666"><%=k%>:</font>           
           </td>
           <td width='55%' style='background:#F9F9F9;'> 
             <font color="#666666"><%=l_g_name%></font>                     
             </td>       
       
          <td width='40%'>
          </td>
          </tr>
          
            <% }  %>          
         
          </table> 
          <%
					          
					 }          
          %>      
      
       </span>   			 
			 			
			</td>
		</tr>  
		
		<tr>
			<td align="right" width="20%">
				推荐配饰:			
			</td>
			<td colspan="3">
        
			 
          <span id="p_goods_table">
           <%
           
           if(!link_fit.trim().equals("")){           
           %>       
          <table width='100%' border='0' cellspacing='0' cellpadding='0' >
          
			   <%
            String l_g_fit[] = link_fit.split("\\|");	
            for(int i=0;i<l_g_fit.length;i++){
              int k =i+1;	
              String l_p_fitname = ti_goodsInfo.getGoodsNameById(l_g_fit[i]);
              if(l_p_fitname.length()>28)
              {
                  l_p_fitname =l_p_fitname.substring(0,28);              
              }	   
			  
			   %>        
             <tr id="p_spandiv<%=k%>">
           	<td width='5%' height='15' align='right' style='background:#F9F9F9;'>
             	<font color="#666666"><%=k%>:</font>           
           </td>
           <td width='55%' style='background:#F9F9F9;'> 
             <font color="#666666"><%=l_p_fitname%></font>                     
             </td>       
       
          <td width='40%'>
                 
       
          </td>
          </tr>
          
            <% }  %>          
         
          </table> 
          <%
					          
					 }          
          %>      
      
       </span>   			 
			 
			 
			 			
			</td>
		</tr>       
       
     
 	    
		
		<tr>
		<td  colspan="4">
			   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">审核信息</span></td>
	    </tr>
     
        <tr>
			<td align="right" width="20%">
				是否通过:			
			</td>
			<td colspan="3">
			  <input type="radio" name="state_code" id="state_code1" onclick="change(0)" checked value="c" />审核通过
			  <input type="radio" name="state_code" id="state_code2" onclick="change(1)" value="b" />审核不通过	
			</td>
			
		</tr> 
		
		  <tr style="display:none;" id="tr_reason">
			<td align="right" width="20%">
				不通过理由:			
			</td>
			<td colspan="3">
			   <textarea name="remark" id="remark" cols="80" rows="8"></textarea>
			</td>
			
		</tr> 
	</table>
	 	<script>
		
		function change(val)
        {
			if(val == 0){
				document.getElementById('tr_reason').style.display = 'none';
			}
			if(val == 1){
				document.getElementById('tr_reason').style.display = '';
			}
	    }
		
		</script>
		
		
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
		    
			<input type="hidden" name="bpm_id" value="8888" />
			
			<input type="button" class="buttoncss" name="tradeSub" value="提交" onClick="audit()"  />&nbsp;&nbsp;
			
			<input type="button" class="buttoncss" name="tradeRut" value="返回" onclick="window.location.href='<%=para%>';"/>
			
			</td>
		</tr>
	</table>
      <input type="hidden" name="jumpurl" value="<%=para%>" />
	  <input type="hidden" name="pkid" id="pkid" value="<%=goods_id%>">

	</form>

</body>

</html>
